Skip to content

O3-5696: Fix Wrong ORM mapping, duplicate DB lookup & null crash - #115

Open
UjjawalPrabhat wants to merge 3 commits into
openmrs:mainfrom
UjjawalPrabhat:O3-5696
Open

O3-5696: Fix Wrong ORM mapping, duplicate DB lookup & null crash#115
UjjawalPrabhat wants to merge 3 commits into
openmrs:mainfrom
UjjawalPrabhat:O3-5696

Conversation

@UjjawalPrabhat

@UjjawalPrabhat UjjawalPrabhat commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Three independent backend defects in the queue module:

  • QueueEntry.queueComingFrom was mapped @OneToOne though many entries can transition from the same source queue. Switch to @ManyToOne, matching the other associations. Mapping correctness only, no behaviour change: Hibernate binds an owning-side @OneToOne with a join column as a ManyToOneType anyway, and the generated schema is identical.

  • AbstractBaseQueueDaoImpl.get(uuid) executed its criteria query twice, discarding the first result. Drop the redundant call so each UUID lookup runs exactly one query (affects all queue DAOs via the base).

  • getDisplay null-checked personName but dereferenced a possibly-null patient first, in both QueueEntryResource and QueueEntrySubResource. Null-check the patient and fall back to the queue entry UUID, in both, with unit tests. Hardening rather than a reproducible crash: patient_id is NOT NULL and validation rejects a null patient, so no in-module path writes such a row. It guards rows written from outside, and makes the two getters agree.

@sonarqubecloud

sonarqubecloud Bot commented Jun 3, 2026

Copy link
Copy Markdown

@jwnasambu

Copy link
Copy Markdown

@claude review

QueueEntrySubResource.getDisplay had the same unguarded patient
dereference as QueueEntryResource, and served the same display property
for the same entity from GET /ws/rest/v1/queue/{uuid}/entry. Guarding
only one getter left that endpoint exposed to the same crash.
@UjjawalPrabhat
UjjawalPrabhat requested a review from dkayiwa July 30, 2026 18:06
Comment thread api/src/main/java/org/openmrs/module/queue/model/QueueEntry.java
@UjjawalPrabhat
UjjawalPrabhat requested a review from dkayiwa August 11, 2026 10:28
@dkayiwa

dkayiwa commented Aug 11, 2026

Copy link
Copy Markdown
Member

@claude review

Aligning QueueEntrySubResource.getDisplay with QueueEntryResource changed
the all-names-voided branch from "" to patient.toString(), and nothing
covered it. That branch is the one known to occur: it dates to 2c4f7f1
"Fix NPE for patients without unvoided names".
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants